/**
 *
 */
package main;

import asa.*;
import AuxComp.*;

/**
 * @author José
 *
 */
public class AtorCompilationUnit {

	public void compile(String nomeAtor, char []input) {
        Compiler compiler = new Compiler();
          // é necessário deixar um espaço a mais depois do fim
          // do vetor para que o compilador coloque '\0'
        char []newInput = new char[input.length + 1];
        for(int i = 0; i < input.length; i++)
        	newInput[i] = input[i];

        Program program  = compiler.compile(newInput);
        compilationErrorList = compiler.getCompilationErrorList();
        if ( program != null ) {
        	PWCharArray pw = new PWCharArray();
        	pw.set();
            program.genJava( pw, nomeAtor );
            generatedCode = pw.getGeneratedString();
        }
	}

	public void setCompilationErrorList(CompilationErrorList compilationErrorList) {
		this.compilationErrorList = compilationErrorList;
	}
	public CompilationErrorList getCompilationErrorList() {
		return compilationErrorList;
	}

	public void setGeneratedCode(StringBuffer generatedCode) {
		this.generatedCode = generatedCode;
	}

	public StringBuffer getGeneratedCode() {
		return generatedCode;
	}

	private CompilationErrorList compilationErrorList;
	private StringBuffer generatedCode;

}
